using System;
using System.Collections.Generic;
using System.Text;

namespace Scenario_Editor.WR2TerrainLoader
{
    class Ground
    {
        ObjectName  groundName;
        ObjectName  temp; //Only to add more 32 Bytes;
        short       dirtiness;
        short       frontGrip;
        short       RearGrip;
        short       Stickiness;
        EnumNoise noise;
        EnumSkidmarks skidmarks;
        byte[] unknown = new byte[64];
        short noCollision;
        byte[] unknown2 = new byte[14];

        internal static Ground FromStream(System.IO.BinaryReader br)
        {
            Ground ground = new Ground();

            ground.groundName = ObjectName.LoadFromStream(br);
            ground.temp = ObjectName.LoadFromStream(br); //Only to add more 32 Bytes;
            ground.dirtiness = br.ReadInt16();
            ground.frontGrip = br.ReadInt16();
            ground.RearGrip = br.ReadInt16();
            ground.Stickiness = br.ReadInt16();
            ground.noise = (EnumNoise)br.ReadInt16();
            ground.skidmarks = (EnumSkidmarks)br.ReadInt16();
            ground.unknown = br.ReadBytes(64);
            ground.noCollision = br.ReadInt16();
            ground.unknown2 = br.ReadBytes(14);

            return ground;
        }

        internal void Save(System.IO.BinaryWriter bw)
        {

            this.groundName.Save(bw); //ground.groundName = ObjectName.LoadFromStream(br);
            this.temp.Save(bw);//ground.temp = ObjectName.LoadFromStream(br); //Only to add more 32 Bytes;
            bw.Write(this.dirtiness);//ground.dirtiness = br.ReadInt16();
            bw.Write(this.frontGrip);//ground.frontGrip = br.ReadInt16();
            bw.Write(this.RearGrip);//ground.RearGrip = br.ReadInt16();
            bw.Write(this.Stickiness); //ground.Stickiness = br.ReadInt16();
            bw.Write((short)this.noise); //ground.noise = (EnumNoise)br.ReadInt16();
            bw.Write((short)this.skidmarks); //ground.skidmarks = (EnumSkidmarks)br.ReadInt16();
            bw.Write(this.unknown);//ground.unknown = br.ReadBytes(64);
            bw.Write(this.noCollision);//ground.noCollision = br.ReadInt16();
            bw.Write(this.unknown2);//ground.unknown2 = br.ReadBytes(14);
        }
    }
}
